package com.sj.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * <p>
 * 标签表
 * </p>
 *
 * @author 孙峻
 * @since 2022-03-09
 */
@Getter
@Setter
@Accessors(chain = true)
@ApiModel(value = "Label对象", description = "标签表")
public class Label implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("标签id 自增长")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("标签名字")
    private String labelName;

    @ApiModelProperty("用户id")
    private Integer userId;

    @ApiModelProperty("是否删除 1 删除 0 未删除")
    @TableLogic
    private Boolean del;

    @ApiModelProperty("创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime createTime;

    @ApiModelProperty("更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime updateTime;

    public static LabelBuilder builder() {
        return new LabelBuilder();
    }

    public static final class LabelBuilder {
        private Integer id;
        private String labelName;
        private Integer userId;
        private Boolean del;
        private LocalDateTime createTime;
        private LocalDateTime updateTime;

        private LabelBuilder() {
        }

        public LabelBuilder id(Integer id) {
            this.id = id;
            return this;
        }

        public LabelBuilder labelName(String labelName) {
            this.labelName = labelName;
            return this;
        }

        public LabelBuilder userId(Integer userId) {
            this.userId = userId;
            return this;
        }

        public LabelBuilder del(Boolean del) {
            this.del = del;
            return this;
        }

        public LabelBuilder createTime(LocalDateTime createTime) {
            this.createTime = createTime;
            return this;
        }

        public LabelBuilder updateTime(LocalDateTime updateTime) {
            this.updateTime = updateTime;
            return this;
        }

        public Label build() {
            Label label = new Label();
            label.setId(id);
            label.setLabelName(labelName);
            label.setUserId(userId);
            label.setDel(del);
            label.setCreateTime(createTime);
            label.setUpdateTime(updateTime);
            return label;
        }
    }
}
